<template>
    <div>
        <VoSchemaForm :model="model" :schema="schema"></VoSchemaForm>
        <div>
            <pre>{{modelJson}}</pre>
        </div>
        <div class="markdown-body">
            <CodeTpl></CodeTpl>
        </div>
    </div>
</template>

<script>
import CodeTpl from '@/views/md/sf/radio.md';
export default {
    components: {
        CodeTpl
    },
    data() {
        return {
            model: {},
            schema: {
                properties: {
                    name1: {
                        label: '单个',
                        widget: 'radio',
                        ui: {}
                    },
                    name2: {
                        label: '多个',
                        widget: 'radio',
                        enum: [
                            { label: '1', value: '选项1' },
                            { label: '2', value: '选项2' },
                            { label: '3', value: '选项3' },
                            { label: '4', value: '选项4' }
                        ]
                    },
                    name3: {
                        label: '按钮模式',
                        widget: 'radioButton',
                        enum: [
                            { label: '1', value: '选项1' },
                            { label: '2', value: '选项2' },
                            { label: '3', value: '选项3' },
                            { label: '4', value: '选项4' }
                        ],
                        ui: {
                            textColor: '#F56C6C',
                            fill: '#67C23A'
                        }
                    },
                    name4: {
                        label: '异步选项',
                        widget: 'radio',
                        enum: [],
                        asyncData() {
                            return new Promise(resolve => {
                                const result = [
                                    { label: '1', value: '选项1' },
                                    { label: '2', value: '选项2' },
                                    { label: '3', value: '选项3' },
                                    { label: '4', value: '选项4', disabled: true }
                                ]
                                setTimeout(() => {
                                    resolve(result)
                                }, 3000)
                            })
                        }
                    }
                },
                ui: {
                    labelWidth: 100
                },
                col: {
                    span: 12
                }
            }
        }
    },
    computed: {
        modelJson() {
            return JSON.stringify(this.model, null, 4)
        }
    }
}
</script>

<style>

</style>
